﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Media;
using IntelligentParkingLot.ViewModels.Base;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using Models;
using SkiaSharp;

namespace IntelligentParkingLot.ViewModels.Pages;

public class DashboardViewModel : BaseViewModel
{
    public SolidColorBrush LegendTextBrush { get; set; } = Brushes.Black;
    public SolidColorBrush LegendBackgroundBrush { get; set; } = Brushes.White;

    /// <summary>
    ///     区域列表
    /// </summary>
    public ObservableCollection<AreaModel> AraeList { get; set; } =
        new ObservableCollection<AreaModel>();

    /// <summary>
    ///     仪表盘列表
    /// </summary>

    public ObservableCollection<BoardModel> BoardList { get; set; } =
        new ObservableCollection<BoardModel>();

    /// <summary>
    ///     停车记录
    /// </summary>
    public ObservableCollection<RecordModel> RecordList { get; set; } =
        new ObservableCollection<RecordModel>();

    /// <summary>
    ///     停车信息
    /// </summary>
    public ObservableCollection<PassRecordItemModel> InfoList { get; set; } =
        new ObservableCollection<PassRecordItemModel>();

    public List<ISeries> Series { get; set; } = new List<ISeries>();

    /// <summary>
    ///     当前日期
    /// </summary>
    public DateTime CurrentDate { get; set; } = DateTime.Now;

    public SolidColorPaint LegendTextPaint { get; set; } =
        new SolidColorPaint
        {
            Color = new SKColor(50, 50, 50),
            SKTypeface = SKFontManager.Default.MatchCharacter('汉')
        };

    public SolidColorPaint LedgendBackgroundPaint { get; set; } =
        new SolidColorPaint(new SKColor(240, 240, 240));

    public DashboardViewModel()
        : base(null)
    {
        PageTitle = "数据中心";
        IsCanClose = false;

        BoardList.Add(
            new BoardModel
            {
                Header = "总收入",
                Value = 568768,
                Color = "#EC9606",
                Icon = "\ue66d"
            }
        );
        BoardList.Add(
            new BoardModel
            {
                Header = "优惠卷(张)",
                Value = 24,
                Color = "#088DF6",
                Icon = "\ue624"
            }
        );
        BoardList.Add(
            new BoardModel
            {
                Header = "会员累计人数",
                Value = 698,
                Color = "#F76E55",
                Icon = "\ue604"
            }
        );
        BoardList.Add(
            new BoardModel
            {
                Header = "当前空车位",
                Value = 80,
                Color = "#0ACEB1",
                Icon = "\ue68f"
            }
        );
        BoardList.Add(
            new BoardModel
            {
                Header = "访客未处理(人)",
                Value = 5,
                Color = "#954AF2",
                Icon = "\ue606"
            }
        );

        // 从数据库获取相关数据
        // 后台有数据后，再做对接
        RecordList.Add(
            new RecordModel
            {
                CarImage = "/Assets;component/Images/covers/huA.jpg",
                Number = "沪A59P65",
                RecordInfo = "测试车辆进出记录，未见异常"
            }
        );
        RecordList.Add(
            new RecordModel
            {
                CarImage = "/Assets;component/Images/covers/wanF.jpg",
                Number = "皖FC001C",
                RecordInfo = "测试车辆进出记录，未见异常"
            }
        );
        RecordList.Add(
            new RecordModel
            {
                CarImage = "/Assets;component/Images/covers/yiB.jpg",
                Number = "冀B850AR",
                RecordInfo = "测试车辆进出记录，未见异常"
            }
        );
        RecordList.Add(
            new RecordModel
            {
                CarImage = "/Assets;component/Images/covers/yueA.jpg",
                Number = "粤AFQ787",
                RecordInfo = "测试车辆进出记录，未见异常"
            }
        );

        Series.Add(
            new PieSeries<ObservableValue>
            {
                Name = "微信支付",
                Values = new ObservableCollection<ObservableValue> { new ObservableValue(16.0) },
                InnerRadius = 40,
                Pushout = 1
            }
        );
        Series.Add(
            new PieSeries<ObservableValue>
            {
                Name = "支付宝支付",
                Values = new ObservableCollection<ObservableValue> { new ObservableValue(22.0) },
                InnerRadius = 40,
                Pushout = 1
            }
        );
        Series.Add(
            new PieSeries<ObservableValue>
            {
                Name = "现金支付",
                Values = new ObservableCollection<ObservableValue> { new ObservableValue(11.0) },
                InnerRadius = 40,
                Pushout = 1
            }
        );
        Series.Add(
            new PieSeries<ObservableValue>
            {
                Name = "优惠减免",
                Values = new ObservableCollection<ObservableValue> { new ObservableValue(39.0) },
                InnerRadius = 40,
                Pushout = 1
            }
        );
        Series.Add(
            new PieSeries<ObservableValue>
            {
                Name = "会员",
                Values = new ObservableCollection<ObservableValue> { new ObservableValue(12.0) },
                InnerRadius = 40,
                Pushout = 1,
            }
        );
    }
}
